package com.bishe.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bishe.dao.UsersDao;
import com.bishe.domain.Users;
import com.bishe.sevice.IUsersService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UsersDao, Users> implements IUsersService {

    @Autowired
    private UsersDao usersDao;
    @Override
    public boolean modify(Users users) {
        return usersDao.updateById(users)>0;
    }

    @Override
    public boolean delete(Integer id) {
        return usersDao.deleteById(id)>0;
    }



    @Override
    public List<Users> GetBy(String uid) {
        QueryWrapper<Users> qw = new QueryWrapper<>();
        qw.like("uid",uid);
        return usersDao.selectList(qw);
    }

    @Override
    public List<Users> GetBy2(String uid,String password) {
        QueryWrapper<Users> qw = new QueryWrapper<>();
        qw.like("uid",uid);
        return usersDao.selectList(qw);
    }

    /**找回密码用**/
    @Override
    public List<Users> GetBykkey(String uid,String kkey) {
        QueryWrapper<Users> qw = new QueryWrapper<>();
        qw.like("uid",uid);
        return usersDao.selectList(qw);
    }

    @Override
    public IPage<Users> getPage(int currentPage, int pageSize ) {
        IPage page = new Page(currentPage,pageSize);
        usersDao.selectPage(page,null);
        return page;
    }
}
